<?php

namespace app\admin\model;

use DI\Annotation\Inject;
use support\Model;

class Attachment extends Model
{

    /**
     * @var \app\admin\service\Attachment
     */
    protected static $service = null;

    protected static function booted(){
        if (self::$service == null) {
            self::$service = app(\app\admin\service\Attachment::class);
        }

        static::deleted(function ($row) {
            self::$service->delete($row->url);
        });
    }
}
